/**
 * @file 列表组件
 * @author its-wild(https://gitee.com/its-wild)
 * @date 2022/11/12
 */
import { Slider, Color, Link, Select, Input, Radio, Mapping } from '@/components/CustomPage/fields/widget'
// import { BasicOption } from './basicops'
import { DataOption } from './dataops'
import CourseListComp from '../widget/course/courseListComp.vue'
import RushListComp from '../widget/rush/rushListComp.vue'
import {
  figureClassifyComp,
  figureListStyleOneComp,
  onlineExam,
  onLineFixedNumberComp

} from '@/components/CustomPage/apps/widget'
import { BasicOption } from '@/components/CustomPage/apps/map/basicops'
import {sourceOption} from "@/components/CustomPage/apps/map/source";
import { imgOption } from '@/components/CustomPage/apps/map/imgops'

export default {
  /**
   * 课程列表组件
   */
  courseListComp() {
    return {
      target: CourseListComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '视频课程列表',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 24,
                max: 100,
                step: 1
              }
            },
            ...imgOption(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Radio,
              option: {
                label: '是否使用瀑布流',
                name: 'isWaterfall',
                list: [
                  { name: '是', value: true },
                  { name: '否', value: false }
                ],
                value: true
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
   * 闯关列表组件
   */
  rushListComp() {
    return {
      target: RushListComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '闯关列表',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            /*   {
              type: Slider,
              option: {
                label: '下边距',
                name: 'bottom',
                value: 0,
                max: 100,
                step: 1
              }
            },*/
            ...imgOption(),
            // { type: Slider, option: { label: '列表高度', name: 'itemHeight', value: 67, max: 100, step: 1 }},
            /* {
              type: Color,
              option: {
                label: '背景颜色',
                name: 'backgroundColor',
                value: '#fff',
                showalpha: true
              }
            },*/
            // { type: Link, option: { label: '详情地址', name: 'link' } },
            // { type: Link, option: { label: '查看排名', name: 'rushRank' }},
            /* {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [{ name: '封面', code: 'imgId', value: '' }, { name: 'oss封面', code: 'imgUrl', value: '' }]
              }
            }*/
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
   * 劳模工匠分类列表
   * @constructor
   */
  figureClassifyComp() {
    return {
      target: figureClassifyComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '劳模工匠分类列表'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...imgOption(),
            { type: Link, option: { label: '链接地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
   * 人物列表
   * @constructor
   */
  figureListStyleOneComp() {
    return {
      target: figureListStyleOneComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '劳模工匠人物列表'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...imgOption(),
            { type: Link, option: { label: '链接地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ]
    }
  },
  /** 考试列表分页组件 **/
  onLineExam() {
    return {
      target: onlineExam,
      parameter: {
        relate: false,
        mold: 'field',
        label: '考试列表分页组件'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 0,
                max: 50,
                step: 1
              }
            },
            { type: Link, option: { label: '链接地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ]
    }
  },
  /** 考试列表分页组件(固定数量) **/
  onLineExamFixedNumber() {
    return {
      target: onLineFixedNumberComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '考试列表(固定数量)'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 0,
                max: 50,
                step: 1
              }
            },
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'pageSize',
                value: 2,
                required: true
              }
            },
            {
              type: Input,
              option: {
                label: '标题名称',
                name: 'modubleName',
                value: '考试列表(固定数量)',
                required: true
              }
            },
            {
              type: Radio,
              option: {
                label: '查看更多展示',
                name: 'isMore',
                type: 'button',
                list: [
                  { name: '展示', value: '1' },
                  { name: '不展示', value: '2' }
                ],
                layout: 'horizon',
                value: '1',
                override: function(ths, e) {
                  // 11 12 13 14
                  ths.$nextTick(() => {
                    const lastIndex = ths.$parent.$parent.$children.length - 2
                    ths.$parent.$parent.$children[lastIndex].visible = e === '1'
                  })
                }
              }
            },
            {
              type: Link,
              option: { label: '更多跳转地址', name: 'moreLink' }
            },

            { type: Link, option: { label: '链接地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ]
    }
  }
}
